<?php
header('content-type:text/html;charset=utf=8');
include 'database/db.php';

$username=$_POST['username'];
$password=$_POST['password'];

$DB = new DB();

$querySql = "select id from user where name=?";
$paramTypeStr = 's';
$params = array(&$username);
$resultSet = $DB->select($querySql, $paramTypeStr, $params);
if ($resultSet) {
    echo "你已经注册，请登录...";
} else {
    $insertSql = "insert into user(name, password) values(?,?)";
    $paramTypeStr = 'ss';
    $params = array(&$username,&$password);
    $result = $DB->update($insertSql, $paramTypeStr, $params);
    if (!$result) {
        echo "用户信息插入失败...";
    } else {
        echo "注册成功!";
    }
}

$DB->close();
